Optimizing Capture Of Focus Stacks

ABSTRACT

Generating a focus stack, including receiving initial focus data that identifies a plurality of target depths, positioning a lens at a first position to capture a first image at a first target depth of the plurality of target depths, determining, in response to capturing the first image and prior to capturing additional images, a sharpness metric for the first image, capturing, in response to determining that the sharpness metric for the first image is an unacceptable value, a second image at a second position based on the sharpness metric, wherein the second position is not included in the plurality of target depths, determining that a sharpness metric for the second image is an acceptable value, and generating a focus stack using the second image.

BACKGROUND

This disclosure relates generally to the field of digital image captureand processing, and more particularly to the field of optimizing captureof focus stacks. A camera can adjust a lens stack to obtain focus on anobject. A camera's autofocus (AF) system, for example, can automaticallyadjust the lens stack to obtain focus on a subject. A particular imagemay have several objects that should be in focus.

Focus stacking combines multiple images having different points of focusto create a final image with better overall focus than the individualimages. Sweeping the lens stack from macro to infinity is required inorder to ensure that all points in the scene are captured in focus. Forexample, a camera may capture images with a lens stack at a series ofpredetermined depths. At each depth, a different portion of the imagemay be in focus. By combining the various images into a focus stack, thefinal image will have multiple points of focus.

By its very nature the use of focus stacks requires capturing multipleimages, resulting in a tradeoff between frame capture and performance.With a low number of frames, there may be parts of the scene that arenot captured in focus, however processing power will be optimal.Conversely, a better result requires the capture of more frames toensure that all parts of the scene can be captured in focus. However,the more images that are captured, the more processing power is requiredand memory to store the various images for processing.

SUMMARY

In one embodiment, a method for optimized capture of focus stacks isdescribed. The method includes receiving initial focus data thatidentifies target depths; positioning a lens at a first position tocapture a first image at a first target depth; determining, in responseto capturing the first image and prior to capturing additional images, asharpness metric for the first image; capturing, in response todetermining that the sharpness metric for the first image is anunacceptable value, a second image at a second position based on thesharpness metric, wherein the second position is not associated with anyof the target depths; determining that a sharpness metric for the secondimage is an acceptable value; and generating a focus stack using thesecond image.

In another embodiment, the method may be embodied in computer executableprogram code and stored in a non-transitory storage device. In yetanother embodiment, the method may be implemented in an electronicdevice having image capture capabilities.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows, in block diagram form, a simplified camera systemaccording to one or more embodiments.

FIG. 2 shows, in flow chart form, a focus stack operation in accordancewith one or more embodiments.

FIG. 3 shows an example flow diagram illustrating various steps taken inoptimizing capture of a focus stack in accordance with one or moreembodiments.

FIG. 4 shows, in block diagram form, a simplified multifunctional deviceaccording to one or more embodiments.

DETAILED DESCRIPTION

This disclosure pertains to systems, methods, and computer readablemedia for optimizing generation of a focus stack. In general, techniquesare disclosed for determining target depths, begin capturing images atthe target depths, and concurrently, while capturing the images at thetarget depths, determining a sharpness metric for each image. If adetermined sharpness metric for a particular image is determined to beunsuitable for the focus stack, the lens is repositioned to take anotherimage with the lens positioned slightly closer or farther at which theunsuitable image was captured before continuing to capture images at thetarget depths. More particularly, in one or more embodiments, a focusstack is generated by receiving initial focus stack data that identifiestarget depths, positioning a lens at a first position to capture a firstimage at a first target depth, determining, in response to thecapturing, a sharpness metric based on the first image, capturing asecond image at a second position based on the sharpness metric, andgenerating a focus stack using the second image. Further, in one or moreembodiments, after the first image is captured, and in response todetermining that the sharpness metric for the second image isacceptable, the lens is positioned at a second target depth of thedetermined target depths, and a third image is captured at the secondtarget depth.

In the following description, for purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the disclosed concepts. As part of this description,some of this disclosure's drawings represent structures and devices inblock diagram form in order to avoid obscuring the novel aspects of thedisclosed embodiments. In this context, it should be understood thatreferences to numbered drawing elements without associated identifiers(e.g., 100) refer to all instances of the drawing element withidentifiers (e.g., 100 a and 100 b). Further, as part of thisdescription, some of this disclosure's drawings may be provided in theform of a flow diagram. The boxes in any particular flow diagram may bepresented in a particular order. However, it should be understood thatthe particular flow of any flow diagram is used only to exemplify oneembodiment. In other embodiments, any of the various components depictedin the flow diagram may be deleted, or the components may be performedin a different order, or even concurrently. In addition, otherembodiments may include additional steps not depicted as part of theflow diagram. The language used in this disclosure has been principallyselected for readability and instructional purposes, and may not havebeen selected to delineate or circumscribe the disclosed subject matter.Reference in this disclosure to “one embodiment” or to “an embodiment”means that a particular feature, structure, or characteristic describedin connection with the embodiment is included in at least oneembodiment, and multiple references to “one embodiment” or to “anembodiment” should not be understood as necessarily all referring to thesame embodiment or to different embodiments.

It should be appreciated that in the development of any actualimplementation (as in any development project), numerous decisions mustbe made to achieve the developers' specific goals (e.g., compliance withsystem and business-related constraints), and that these goals will varyfrom one implementation to another. It will also be appreciated thatsuch development efforts might be complex and time consuming, but wouldnevertheless be a routine undertaking for those of ordinary skill in theart of image capture having the benefit of this disclosure.

For purposes of this disclosure, the term “lens” refers to a lensassembly, which could include multiple lenses, which may be moved tovarious positions to capture images at multiple depths and, as a result,multiple points of focus. As such, the term lens can mean a singleoptical element or multiple elements configured into a stack or otherarrangement.

For purposes of this disclosure, the term “focus stack” may describeimages capturing a same object, where each image is captured with thelens at a different focus distance.

Referring to FIG. 1, a simplified block diagram of camera system 100 isdepicted, in accordance with one or more embodiments of the disclosure.Camera system 100 may be part of a camera, such as a digital camera.Camera system 100 may also be part of a multifunctional device, such asa mobile phone, tablet computer, personal digital assistant, portablemusic/video player, or any other electronic device that includes acamera system.

Camera system 100 may include a lens 105. More specifically, asdescribed above, lens 105 may actually include a lens assembly, whichmay include a number of optical lenses, each with various lenscharacteristics. For example, each lens may include its own physicalimperfections that impact the quality of an image captured by theparticular lens. When multiple lenses are combined, for example in thecase of a compound lens, the various physical characteristics of thelenses may impact the characteristics of images captured through thelens assembly, such as focal points.

As depicted in FIG. 1, camera system 100 may also include an imagesensor 110. Image sensor 110 may be a sensor that detects and conveysthe information that constitutes an image. Light may flow through thelens 105 prior to being detected by image sensor 110 and be stored, forexample, in memory 115.

In one or more embodiments, the camera system 100 may also includemechanical stops 120 (120 a, 120 b, 120 c, and 120 d). The variousmechanical stops 120 may delineate the full range of motion 125 withinwhich the lens 105 may move to capture images at various positions. Inone or more embodiments, mechanical stops 120 b and 120 d representmacro stops, and mechanical stops 120 a and 120 c represent infinitystops. The lens 105 may be moved within the full range of motion 125 tocapture images at various distances between the macro stops and theinfinity stops. Capturing images at different lens positions may resultin various images with different points of focus, or with various pointsin the scene being more or less in focus. Thus, depending on theposition of the lens when images are captured, different objects in theimage, or portions of the image, may appear to be in focus. In one ormore embodiments, actuator 130 displaces the lens 105 between mechanicalstops 120. In one or more embodiments, the camera system may includemore than one camera, each including its own lens apparatus, mechanicalstops, and the like.

Also included in camera system 100 is an orientation sensor 135 and modeselect input 140, both of which supply input to control unit 145. In oneembodiment, an image capture device may use a charged coupled device (ora complementary metal-oxide semiconductor as image sensor 110), anelectro-mechanical unit (e.g., a voice coil motor) as actuator 130 andan accelerometer as orientation sensor 135.

Turning to FIG. 2, an example method for generating a focus stack isdepicted in the form of a flow chart. The flow chart begins at 205 wherethe image capture system receives initial focus data that identifiessuitable target depths, or focus distances. The target depths mayinclude an estimation of the most important depths in a scene at which alimited number of images should be captured. In one or more embodiments,the initial focus data may be received in the form of a depth map.Further, in one or more embodiments, the focus data may be obtainedduring an autofocus operation, or may be received using a sensor duringa preview mode. In one or more embodiments, the initial focus data maybe received using hardware intended to measure distances to an object ina scene, such as a laser range finder, or stereo cameras which may bematched (two cameras having identical focal lengths) or unmatched (twocameras having different focal lengths such as, for example, awide-angle lens/camera and a telephoto lens/camera). Further, receivingthe initial focus data may include a phase detect portion. The phasedetect portion may provide a rough estimation for how to move the lensinto focus for one or more points of interest in the scene. For example,during the phase detect portion, the control 145 may identifyapproximately what focus stop or stops will provide an image with one ormore objects of interest in focus.

The flow chart continues at 210, and the lens (or one of the availablelenses) is positioned at a first target depth to capture a first image.For example, referring to FIG. 1, the actuator 130 may move the lens 105to a position associated with the first target depth identified in theinitial focus data. The image may be captured using the image sensor 110and stored in the memory 115.

The flow chart continues at 215 and a determination is made regardingwhether a sharpness metric for the image is an acceptable value. In oneor more embodiments, the sharpness metric is determined by analyzing theimage to detect edges and determining the sharpness of the detectededges. That is, in one or more embodiments, the sharpness metric isdetermined by analyzing edge strength of the image or in one or moreportions of the image. For example, a set of filters may be applied tothe image to determine the strength of the edges. The sharpness metricmay be represented as a numerical value, or by any other means thatidentifies the sharpness or relative sharpness of the image or designateportion thereof. Determining whether the sharpness metric for the imageis an acceptable value may include comparing the determined sharpnessmetric to a predefined sharpness threshold. For example, a particularsharpness may be required to be used in generating the focus stack. Therequired sharpness may be expressed in the form of a calculated number,or in the form of a particular step on a scale. In addition, thesharpness required may be modified or recalculated at run time, based oncharacteristics of the image capture system, or environmental factors,for example. In one or more embodiments, the sharpness metric may becompared to the sharpness threshold to determine if the image isacceptable for including in the focus stack.

In one or more embodiments, the sharpness metric may also be determinedbased on a comparison of characteristics between a current image andpreviously captured images at different target depths. For example, thevarious techniques used to determine initial focus data, such as stereocameras and phase detect information, may be evaluated at each image.

If at 215 it is determined that the sharpness metric is not anacceptable value, then the flow chart continues at 220, and theplurality of target depths is refined. For example, if the sharpnessmetric indicates that the edges are not sufficiently sharp, then thelens may be moved to a new position that may be slightly closer orfarther than the first position in order to capture another image priorto moving on to the next target depth. In one or more embodiments, phasedetect information or stereo camera information may be captured witheach image, and an analysis of the information between images during asweep of the target depths may indicate which direction to move thelens. In addition, the phase detect information may also indicate adistance to the next new target depth.

In one or more embodiments, the sharpness metric may be calculated onthe fly while the lens is in motion. For example, while the lens 105 isin motion from the first target depth to the second target depth, thecontrol 145 may determine that a sharpness metric for the first image isinsufficient. In response, the lens 105 may be repositioned to captureanother image closer to the depth of the first image in order to obtainan image with better sharpness for that target depth. Thus, while thelens is moving from a first target depth to a second target depth, itmay be determined that the image captured at the first target depth isnot sufficiently sharp, and another image should be captured nearer, butslightly off of the first target depth. Thus, at 220, the plurality oftarget depths is refined, and the lens returns near the first targetdepth to capture one or more additional images to ensure that an imagerepresenting the first target depth is captured with sufficientsharpness for the focus stack prior to the lens continuing on to thenext target depth.

After a captured image is considered to have an acceptable sharpnessmetric value at 215, the flow chart continues to 230. At 230 adetermination is made regarding whether there are additional targetdepths in the plurality of target depths. In one or more embodiments, ifit is determined that there are additional target depths identifiedeither in the initial focus data, or in a refined plurality of targetdepths, then the flow chart continues at 225 and a next image iscaptured at a next target depth. In one or more embodiments, the lensmay be repositioned to the next target depth in response to capturing alast image at a last target depth. The flow chart continues at 215 and adetermination is made regarding whether a sharpness metric for the imageis an acceptable value. If at 215 it is determined that the sharpnessmetric is not an acceptable value, the flow chart continues at 220, andthe plurality of target depths is refined. Then at 225, a next image iscaptured at a next target depth. The actions depicted in 215, 220, and225 may be repeated until the sharpness metric is deemed acceptable.

When the image is considered to have an acceptable sharpness metricvalue at 215, and at 230 it is determined that there are no more targetdepths, the method continues at 235. At 235, the focus stack isgenerated using the images for which the sharpness metric was deemedacceptable at 215. The result is a collection of images (a focus stack),each having a different focus depth. In one or more embodiments, thefocus stack may be utilized to generate an all-focused image, in which asingle image includes various depths of focus. In one or moreembodiments, the focus stack may also be used to generate a depth mapusing Depth From Focus (DFF). Specifically, in one or more embodiments,optimizing the capture of images with different focus may allow a betterdepth map to be obtained using a lower number of images.

It should be understood that the various components of the flow chartdescribed above may be performed in a different order or simultaneously,and some components may even be omitted in one or more embodiments.

Referring now to FIG. 3, an example flow diagram depicting a lens system300 at various positions, along with an example image 305 captured ateach position. It should be understood that the example shown in FIG. 3is depicted merely for purposes of clarity, and is not intended to limitthe disclosure. For purposes of this example, initial focus dataindicates two target depths: target depth A and target depth B. In oneor more embodiments, the target depths may be determined prior tocapturing the images, for example during an autofocus procedure, or froma focus map, or during some other preliminary measurement.

The flow diagram begins with Lens System 300 a capturing image 305 a attarget depth A. In the example, the captured scene includes a cloud anda lightning bolt, where target depth A is intended to capture thelightning bolt in focus. Both are shown in gray scale to indicate thatthe sharpness is poor. In one or more embodiments, the camera system maycalculate a sharpness metric for image 305 a to determine that thesharpness metric is unsatisfactory. For example, in one or moreembodiments, the camera system may determine that the edge strength ofone or more of the components in the scene captured in image A 305 ainclude strong edges. For purposes of the example, a camera system maydetermine that the sharpness metric for image A 305 a is unacceptable.In one or more embodiments, the camera system may calculate thesharpness metric for image A 305 a after capturing the image, and whilethe lens is in motion between target depth A and target depth B.

In response to determining that the sharpness metric for image A 305 ais unacceptable, the flow diagram continues to the system depicted aslens system 300 b. Specifically, the lens is redirected back towardtarget depth A to capture image B 305 b at a depth slightly closer toinfinity than target depth A. The result is that the edge strength ofthe lightning bolt in image B 305B is much crisper, as depicted by thebold black line.

In response to determining that the sharpness metric for image B 305 bis acceptable, the lens is moved to target depth B as depicted in lenssystem 300 c. It should be understood that in one or more embodiments,the lens is moving between the position depicted in lens system 300 band lens system 300 c (i.e., target depth B), while the camera system iscalculating the sharpness metric for image B 305 b and determining thatthe sharpness metric is acceptable. With lens at target depth B, image C305 c may be captured. As depicted, the lightning bolt is now shown ingray scale to indicate that it is out of focus, and the cloud isdepicted with a sharp black line to indicate that it is in focus. Thecamera system may determine that the sharpness metric for image C 305 cis acceptable.

Because the lens has captured images at each target depth, focus stack320 may be generated. In one or more embodiments, focus stack 320 may begenerated, which may be a collection of only the captured images thathave an acceptable sharpness metric value (i.e., image B 305 b and imageC 305 c). The result of the optimized capture of images to form focusstack 320, both the cloud and the lightning bolt are depicted in focusin the form of an all-focused image generated from the focus stack, anda minimal number of images were captured.

Referring now to FIG. 4, a simplified functional block diagram ofillustrative multifunction device 400 is shown according to oneembodiment. Multifunction electronic device 400 may include processor405, display 410, user interface 415, graphics hardware 420, devicesensors 425 (e.g., proximity sensor/ambient light sensor, accelerometerand/or gyroscope), microphone 430, audio codec(s) 435, speaker(s) 440,communications circuitry 445, digital image capture unit 450 (e.g.,including camera system 100) video codec(s) 455 (e.g., in support ofdigital image capture unit 450), memory 460, storage device 465, andcommunications bus 470. Multifunction electronic device 400 may be, forexample, a digital camera or a personal electronic device such as apersonal digital assistant (PDA), personal music player, mobiletelephone, or a tablet computer.

Processor 405 may execute instructions necessary to carry out or controlthe operation of many functions performed by device 400 (e.g., such asthe generation and/or processing of images as disclosed herein).Processor 405 may, for instance, drive display 410 and receive userinput from user interface 415. User interface 415 may allow a user tointeract with device 400. For example, user interface 415 can take avariety of forms, such as a button, keypad, dial, a click wheel,keyboard, display screen and/or a touch screen. Processor 405 may also,for example, be a system-on-chip such as those found in mobile devicesand include a dedicated graphics processing unit (GPU). Processor 405may be based on reduced instruction-set computer (RISC) or complexinstruction-set computer (CISC) architectures or any other suitablearchitecture and may include one or more processing cores. Graphicshardware 420 may be special purpose computational hardware forprocessing graphics and/or assisting processor 405 to process graphicsinformation. In one embodiment, graphics hardware 420 may include aprogrammable GPU.

Sensor and camera circuitry 450 may capture still and video images thatmay be processed in accordance with this disclosure, at least in part,by video codec(s) 455 and/or processor 405 and/or graphics hardware 420,and/or a dedicated image processing unit incorporated within circuitry450. Images so captured may be stored in memory 460 and/or storage 465.Memory 460 may include one or more different types of media used byprocessor 405 and graphics hardware 420 to perform device functions. Forexample, memory 460 may include memory cache, read-only memory (ROM),and/or random access memory (RAM). Storage 465 may store media (e.g.,audio, image and video files), computer program instructions orsoftware, preference information, device profile information, and anyother suitable data. Storage 465 may include one more non-transitorystorage mediums including, for example, magnetic disks (fixed, floppy,and removable) and tape, optical media such as CD-ROMs and digital videodisks (DVDs), and semiconductor memory devices such as ElectricallyProgrammable Read-Only Memory (EPROM), and Electrically ErasableProgrammable Read-Only Memory (EEPROM). Memory 460 and storage 465 maybe used to tangibly retain computer program instructions or codeorganized into one or more modules and written in any desired computerprogramming language. When executed by, for example, processor 405 suchcomputer program code may implement one or more of the methods describedherein.

In practice, it has been found beneficial to use multiple lens ratherthan a single lens as suggested above. Thus, lens 105 may be understoodto represent a lens assembly that may have, for example, 2 to 7individual lens elements. Further, entirely different lens systems maybe used to capture images used to form a focus stack. By way of example,one lens system may be a telephoto lens system while a second lenssystem may be a wide-angle lens system. In addition, the number ofpoints-of-interest and the use of a voice coil motor as an actuator areillustrative only. As is the direction of autofocus operations whichwere described as evaluating points-of-interest from infinity to theclosest point at which the image capture device can focus.

Finally, variations of the above-described embodiments may be used incombination with each other. Many other embodiments will be apparent tothose of skill in the art upon reviewing the above description. Thescope of the disclosed subject matter therefore should be determinedwith reference to the appended claims, along with the full scope ofequivalents to which such claims are entitled. In the appended claims,the terms “including” and “in which” are used as the plain-Englishequivalents of the respective terms “comprising” and “wherein.”

1. A method of generating a focus stack, comprising: receiving initialfocus data that identifies a plurality of target depths; positioning alens at a first position to capture a first image at a first targetdepth of the plurality of target depths; determining, in response tocapturing the first image and prior to capturing additional images, asharpness metric for the first image; capturing, in response todetermining that the sharpness metric for the first image is anunacceptable value, a second image at a second position based on thesharpness metric, wherein the second position is not included in theplurality of target depths; determining that a sharpness metric for thesecond image is an acceptable value; and generating a focus stack usingthe second image.
 2. The method of claim 1, further comprising:positioning, in response to determining that the sharpness metric forthe second image is an acceptable value, the lens at a second targetdepth of the plurality of target depths; and capturing a third image atthe second target depth.
 3. The method of claim 1, wherein the sharpnessmetric is calculated concurrently to moving the lens to a second targetdepth of the plurality of target depths.
 4. The method of claim 1,further comprising, redirecting, in response to calculating thesharpness metric, the lens to the second position to capture the secondimage based on the sharpness metric, wherein the second position isassociated with a new target depth that is not included in the initialfocus data.
 5. The method of claim 1, further comprising: generating anall-focused image using the focus stack.
 6. The method of claim 1,further comprising: generating a depth map using the focus stack.
 7. Themethod of claim 1, further comprising: determining, in response tocapturing the second image and prior to capturing additional images, anew sharpness metric based on the second image; capturing a third imageat a third position based on the new sharpness metric; and modifying thefocus stack using the third image.
 8. A system for generating a focusstack, comprising: a lens assembly; a digital image sensor configured toreceive light from the lens assembly; and a memory operatively coupledto the digital image sensor and comprising computer code configured tocause one or more processors to: receive initial focus data thatidentifies a plurality of target depths; position a lens at a firstposition to capture a first image at a first target depth of theplurality of target depths; determine, in response to capturing thefirst image and prior to capturing additional images, a sharpness metricfor the first image; capture, in response to determining that thesharpness metric for the first image is an unacceptable value, a secondimage at a second position based on the sharpness metric, wherein thesecond position is not included in the plurality of target depths;determining that a sharpness metric for the second image is anacceptable value; and generating a focus stack using the second image.9. The system of claim 8, the computer code further configured to causethe one or more processors to: position, in response to determining thatthe sharpness metric for the second image is an acceptable value, thelens at a second target depth of the plurality of target depths; andcapture a third image at the second target depth.
 10. The system ofclaim 8, wherein the sharpness metric is calculated concurrently tomoving the lens to a second target depth to capture a second intendedimage.
 11. The system of claim 8, the computer code further configuredto cause one or more processors to redirect, in response to calculatingthe sharpness metric, the lens to the second position to capture thesecond image based on the sharpness metric, wherein the second positionis associated with a new target depth that is not included in theinitial focus data.
 12. The system of claim 8, wherein the computer codeis further configured to cause the one or more processors to generate anall-focused image using the focus stack.
 13. The system of claim 8,wherein the computer code is further configured to cause the one or moreprocessors to generate a depth map using the focus stack.
 14. The systemof claim 8, the computer code further configured to cause one or moreprocessors to: determine, in response to capturing the second image andprior to capturing additional images, a new sharpness metric based onthe second image; capture a third image at a third position based on thenew sharpness metric; and modify the focus stack using the third image.15. A computer readable medium comprising computer code for generating afocus stack, the computer code executable by one or more processors to:receive initial focus data that identifies a plurality of target depths;position a lens at a first position to capture a first image at a firsttarget depth of the plurality of target depths; determine, in responseto capturing the first image and prior to capturing additional images, asharpness metric for the first image; capture, in response todetermining that the sharpness metric for the first image is anunacceptable value, a second image at a second position based on thesharpness metric, wherein the second position is not included in theplurality of target depths; determining that a sharpness metric for thesecond image is an acceptable value; and generating a focus stack usingthe second image.
 16. The computer readable medium of claim 15, thecomputer code further executable by one or more processors to: position,in response to determining that the sharpness metric for the secondimage is an acceptable value, the lens at a second target depth of theplurality of target depths; and capture a third image at the secondtarget depth.
 17. The computer readable medium of claim 15, wherein thesharpness metric is calculated concurrently to moving the lens to asecond target depth to capture a second intended image.
 18. The computerreadable medium of claim 15, the computer code further executable by oneor more processors to redirect, in response to calculating the sharpnessmetric, the lens to the second position to capture the second imagebased on the sharpness metric, wherein the second position is associatedwith a new target depth that is not included in the plurality of targetdepths.
 19. The computer readable medium of claim 15, the computer codefurther executable by one or more processors to generate an all-focusedimage using the focus stack.
 20. The computer readable medium of claim15, the computer code further executable by one or more processors togenerate a depth map using the focus stack.
 21. The computer readablemedium of claim 15, the computer code further executable by the one ormore processors to: determine, in response to capturing the second imageand prior to capturing additional images, a new sharpness metric basedon the second image; capture a third image at a third position based onthe new sharpness metric; and modify the focus stack using the thirdimage.